/**
 * 给定地图和一段移动方式，问有多少个点可以作为起点
 * 使得按照上述方式移动不会碰到障碍物。
 * 直接枚举每个点走一遍即可，最多O(500^3)
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

array<array<int, 2>, 256> D;

int N;
int H, W;
string T;
vector<string> Board;

bool isOK(int r, int c){
    for(auto ch : T){
        const auto & d = D[ch];
        r += d[0], c += d[1];
        if(0 <= r and r < H and 0 <= c and c < W and '.' == Board[r][c]){

        }else{
            return false;
        }
    }
    return true;
}

int proc(){
    // int maxx = -1, minx = N + 1;
    // int maxy = -1, miny = N + 1;
    // int x = 0, y = 0;
    // for(auto ch : T){
    //     auto & d = D[ch];
    //     x += d[0], y += d[1];

    // }
    int ans = 0;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if('.' == Board[i][j] and isOK(i, j)){
                ++ans;
            }
        }
    }
    return ans;
}

void work(){
    D['L'] = {0, -1};
    D['R'] = {0, 1};
    D['U'] = {-1, 0};
    D['D'] = {1, 0};

    cin >> H >> W >> N >> T;
    Board.assign(H, {});
    for(auto & s : Board) cin >> s;
    cout << proc() << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}